<%@ Page Language="C#" MasterPageFile="~/Site.master" Theme="Default" EnableTheming="true" 
    AutoEventWireup="true" CodeFile="ManageBooks.aspx.cs" Inherits="ManageBooks" 
    Title="Dr. Yurttas' Office Library &mdash; Manage Books" %>
<asp:Content ID="ContentAdmin" ContentPlaceHolderID="MasterContentAdmin" Runat="Server">
    <asp:LoginView ID="LoginViewAdmin" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="admin">
                <ContentTemplate>
                    <asp:GridView Width="100%" ID="bookListView" runat="server" AllowPaging="True" 
                        OnRowCommand="bookListView_RowCommand" DataSourceID="SqlDataSource1" 
                        AutoGenerateColumns="False" AutoGenerateEditButton="False" AutoGenerateDeleteButton="False" 
                        AllowSorting="True" DataKeyNames="bookid">
                        <Columns>
                            <asp:CommandField ControlStyle-Font-Size="0.8em" ControlStyle-Font-Names="Verdana" 
                                ControlStyle-BorderStyle="Solid" ControlStyle-BorderWidth="1px" 
                                ControlStyle-BorderColor="#CCCCCC" ControlStyle-ForeColor="#284775" 
                                ControlStyle-BackColor="#FFFBFF" ButtonType="Button" SelectText="Select" 
                                ShowSelectButton="true" />
                            <asp:BoundField DataField="bookid" HeaderText="ISBN" SortExpression="bookid" 
                                ReadOnly="True" InsertVisible="False" Visible="True" />
                            <asp:HyperLinkField DataTextField="title" 
                                DataNavigateUrlFormatString="http://www.amazon.com/gp/product/{0}" 
                                DataNavigateUrlFields="bookid" HeaderText="Title" SortExpression="title" />
                        </Columns>
                    </asp:GridView>
                    <br />
                    <div>
                    <asp:Label BackColor="#5D7B9D" CssClass="block" Font-Bold="True" ForeColor="White" 
                        Text="&nbsp;&nbsp;Details:" runat="server" ID="detailsLabel" Width="100%"></asp:Label>
                    <asp:DetailsView Width="100%" runat="server" ID="bookDetailsView" 
                        DataSourceID="SqlDataSource1" DataKeyNames="bookid" AutoGenerateEditButton="True" 
                        AutoGenerateDeleteButton="True" AutoGenerateRows="false" >
                        <Fields>
                            <asp:BoundField HeaderStyle-Width="100px" DataField="bookid" HeaderText="ISBN" 
                                ReadOnly="True" InsertVisible="False" Visible="True" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="title" HeaderText="Title" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="author" HeaderText="Author" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="publisher" HeaderText="Publisher" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="language" HeaderText="Language" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="number" HeaderText="Number" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="requested" HeaderText="Requested" />
                        </Fields>
                    </asp:DetailsView>    
                    </div>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:sylib %>"
                        SelectCommand="SELECT bookid, title, publisher, substring(title,0,25) AS shortTitle, 
                            substring(author,0,10) as shortAuthor, author, substring(publisher,0,15) AS shortPublisher,
                            language, number, requested FROM [books] ORDER BY [author], [title], [publisher]"
                        UpdateCommand="UPDATE [books] SET [title] = @title, [author] = @author, 
                            [publisher] = @publisher, [language] = @language, [requested] = @requested, 
                            [number] = @number WHERE [bookid] = @bookid"
                        DeleteCommand="DELETE FROM [books] WHERE [bookid] = @bookid" 
                        ProviderName="System.Data.SqlClient">
                        <DeleteParameters>
                            <asp:Parameter Name="bookid" Type="String" />
                        </DeleteParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="bookid" Type="String" />
                            <asp:Parameter Name="title" Type="String" />
                            <asp:Parameter Name="author" Type="String" />
                            <asp:Parameter Name="publisher" Type="String" />
                            <asp:Parameter Name="language" Type="String" />
                            <asp:Parameter Name="status" Type="String" />
                            <asp:Parameter Name="number" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentUser" ContentPlaceHolderID="MasterContentUser" Runat="Server">
    <asp:LoginView ID="LoginViewUser" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="user">
                <ContentTemplate>
                    Sorry, you do not have access to this page.
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentAnonymous" ContentPlaceHolderID="MasterContentAnonymous" Runat="Server">
    <asp:LoginView ID="LoginViewAnonymous" runat="server">
        <AnonymousTemplate>
            Sorry, you do not have access to this page.
        </AnonymousTemplate>
    </asp:LoginView>                       
</asp:Content>